package cn.lili.modules.member.entity.dto;

import cn.lili.common.security.enums.SceneEnums;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * 用户编辑DTO
 *
 * @author liushuai(liushuai711 @ gmail.com)
 * @version v4.0
 * @Description:
 * @since 2023/4/24 10:16
 */

@SuperBuilder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserEditDTO {

    private String id;

    @Size(max = 50, message = "密码长度不能超过50位")
    private String password;
    @Size(min = 4, max = 20, message = "昵称长度必须在4-20之间")
    private String nickName;
    @Min(value = -1, message = "性别只能为-1,0,1")
    @Max(value = 1, message = "性别只能为-1,0,1")
    private Integer sex;

    @Size(max = 255, message = "头像图片地址长度不能超过255位")
    private String face = "https://feiyu-lshop-test.oss-cn-beijing.aliyuncs.com/default.png";


    @ApiModelProperty(value = "场景")
    private SceneEnums scene;
    @ApiModelProperty(value = "超级管理员")
    private Boolean isSuper = false;

    /**
     * 可以简介理解为场景下的id，与scene同步联用
     */
    @ApiModelProperty(value = "该场景下的id")
    private String extendId;
    /**
     * 可以简介理解为场景下的id，与scene同步联用
     */
    @ApiModelProperty(value = "该场景下的名称")
    private String extendName;

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "生日")
    private Date birthday;

    @ApiModelProperty(value = "是否是店主")
    private Boolean shopkeeper;

    @Size(max = 255, message = "部门编号长度不能超过255位")
    @ApiModelProperty(value = "所属部门id")
    private String departmentId;

    @Size(max = 3, message = "最多赋予3个角色")
    @ApiModelProperty(value = "角色id集合")
    private List<String> roleIds;


    public String getRoleIdsStr() {
        if (roleIds != null && !roleIds.isEmpty()) {
            return String.join(",", roleIds);
        }
        return "";
    }

}
